﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace TMDT.BusinessObjects
{
    public class SanPham
    {
        public Guid IDSanPham { get; set; }
        public Guid IDLoaiSanPham { get; set; }
        public Guid IDNguoiBan { get; set; }
        public Guid IDNhaSanXuat { get; set; }
        public bool IsAn { get; set; }
        public bool IsKhuyenMai { get; set; }
        public string NoiDungKhuyenMai { get; set; }
        public DateTime NgayTao { get; set; }
        public int SoLuotXem { get; set; }
        public int SoLuong { get; set; }
        public int ThoiGianBaoHanh { get; set; }
        public decimal Gia { get; set; }
        public string TenSanPham { get; set; }

        public static SanPham Convert(DataRow row)
        {
            SanPham sanPham = new SanPham();
            sanPham.IDSanPham = new Guid(row["IDSanPham"].ToString());
            sanPham.IDLoaiSanPham = new Guid(row["IDLoaiSanPham"].ToString());
            sanPham.IDNguoiBan = new Guid(row["IDNguoiBan"].ToString());
            sanPham.IDNhaSanXuat = new Guid(row["IDNhaSanXuat"].ToString());
            sanPham.IsAn = bool.Parse(row["IsAn"].ToString());
            sanPham.IsKhuyenMai = bool.Parse(row["IsKhuyenMai"].ToString());
            sanPham.NoiDungKhuyenMai = row["NoiDungKhuyenMai"].ToString();
            sanPham.NgayTao = DateTime.Parse(row["NgayTao"].ToString());
            sanPham.SoLuotXem = int.Parse(row["SoLuotXem"].ToString());
            sanPham.SoLuong = int.Parse(row["SoLuong"].ToString());
            sanPham.ThoiGianBaoHanh = int.Parse(row["ThoiGianBaoHanh"].ToString());
            sanPham.Gia = decimal.Parse(row["Gia"].ToString());
            sanPham.TenSanPham = row["TenSanPham"].ToString();

            return sanPham;
        }
    }
}
